package com.jims.master.modules.patient.myRecord.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.jims.master.common.persistence.DataEntity;
import com.jims.master.modules.base.netHosptial.entity.NetDataIcd10;
import com.jims.master.modules.sys.entity.Dict;

import java.util.ArrayList;
import java.util.List;

/**
 * 用于病历同步中诊断
 * @author xueyx
 * @version 2015-12-27
 * */
public class CaseDiagnosis extends DataEntity<CaseDiagnosis> {

	private static final long serialVersionUID = 1L;
	private String parentId;		// 父级id
	private String diagnosisId;		// 诊断id
	private String type; //诊断类型 1：初步诊断
	private String parentIds; // 诊断父级
	private Integer itemNo;		// 诊断序号
	private List<CaseDiagnosis> emrDiagnosisList;
	private NetDataIcd10 netDataIcd10;       //icd10
	private Dict dict;
	private String description;   //诊断描述
	private String basis; // 诊断依据
    private String clinicId; // 门诊ID
	private List list=new ArrayList();   //父类ID集合
	private boolean isno;  //判断查询全部集合
	//private List<UserSignature> userSignatures=new ArrayList<UserSignature>(); //签名信息
	public CaseDiagnosis() {
		super();
		isno=false;
	}

	public String getBasis() {
		return basis;
	}

	public void setBasis(String basis) {
		this.basis = basis;
	}

	public CaseDiagnosis(String id){
		super(id);
	}

	public List getList() {
		return list;
	}

	public void setList(List list) {
		this.list = list;
	}

	public String getDescription() {
		return description;
	}

	/*public List<UserSignature> getUserSignatures() {
		return  UserSignaturesUtils.getUserSignature(id);
	}

	public void setUserSignatures(List<UserSignature> userSignatures) {
		this.userSignatures = userSignatures;
	}*/

	public void setDescription(String description) {
		this.description = description;
	}

	public String getDiagnosisId() {
		return diagnosisId;
	}

	public void setDiagnosisId(String diagnosisId) {
		this.diagnosisId = diagnosisId;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getParentIds() {
		return parentIds;
	}

	public void setParentIds(String parentIds) {
		this.parentIds = parentIds;
	}

	public Integer getItemNo() {
		return itemNo;
	}

	public void setItemNo(Integer itemNo) {
		this.itemNo = itemNo;
	}



	public List<CaseDiagnosis> getEmrDiagnosisList() {
		return emrDiagnosisList;
	}

	public void setEmrDiagnosisList(List<CaseDiagnosis> emrDiagnosisList) {
		this.emrDiagnosisList = emrDiagnosisList;
	}

	public NetDataIcd10 getNetDataIcd10() {
		return netDataIcd10;
	}

	public void setNetDataIcd10(NetDataIcd10 netDataIcd10) {
		this.netDataIcd10 = netDataIcd10;
	}

	public boolean isIsno() {
		return isno;
	}

	public void setIsno(boolean isno) {
		this.isno = isno;
	}

	public Dict getDict() {
		return dict;
	}

	public void setDict(Dict dict) {
		this.dict = dict;
	}



	@JsonIgnore
	public static void sortList(List<CaseDiagnosis> list, List<CaseDiagnosis> sourcelist, String parentId, boolean cascade){
		for (int i=0; i<sourcelist.size(); i++){
			CaseDiagnosis e = sourcelist.get(i);
			if (e.getParentIds()!=null && e.getParentIds()!=null
					&& e.getParentIds().equals(parentId)){
				list.add(e);
				if (cascade){
					// 判断是否还有子节点, 有则继续获取子节点
					for (int j=0; j<sourcelist.size(); j++){
						CaseDiagnosis child = sourcelist.get(j);
						if (child.getParentIds()!=null && child.getParentIds()!=null
								&& child.getParentIds().equals(e.getId())){
							sortList(list, sourcelist, e.getId(), true);
							break;
						}
					}
				}
			}
		}
	}

	@JsonIgnore
	public static String getParentIdsId(){
		return "0";
	}

    public String getClinicId() {
        return clinicId;
    }

    public void setClinicId(String clinicId) {
        this.clinicId = clinicId;
    }
}